import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:kunlun_gas/app_files.dart';

import 'action.dart';
import 'state.dart';

Widget buildView(
    GasChargeViewState state, Dispatch dispatch, ViewService viewService) {
  return Scaffold(
    appBar: myAppBar(viewService.context, title: '购气充值'),
    backgroundColor: Colors.white,
    body: MyInkWellWidget(
      child:  Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            padding: EdgeInsets.only(left: 15, top: 18),
            width: double.infinity,
            height: 75,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    Text(
                      state.model.title,
                      style: TextThemeConfig.Font15WithBigColor22,
                    ),
                    Padding(padding: EdgeInsets.only(left: 10)),
                    Text(
                      state.model.gasNo,
                      style: TextThemeConfig.Font13WithColor22,
                    ),
                    Container(
                      width: 1,
                      height: 12,
                      margin: EdgeInsets.only(left: 6, right: 6, top: 1),
                      color: Color(0xff999999),
                    ),
                    Padding(
                      padding: EdgeInsets.only(right: 5),
                      child: Image.asset('images/ic_blue_tooth.png'),
                    ),
                    state.bluetoothInfo.length != 0
                        ? Text(
                      state.bluetoothInfo,
                      style: TextThemeConfig.Font13WithColorblue,
                    )
                        : MyInkWellWidget(
                      child: Text(
                        '绑定蓝牙读卡器',
                        style: TextThemeConfig.Font13WithColorblue,
                      ),
                      onTap: () => CommonUtils.pushRoute(
                          viewService.context, RoutePath.bindBlueToothView,
                          arguments: {
                            'userID': state.model.userID,
                          }),
                    ),
                  ],
                ),
                Padding(padding: EdgeInsets.only(top: 4)),
                Text(
                  state.model.address,
                  style: TextThemeConfig.Font13WithColor99,
                ),
              ],
            ),
          ),
          Container(
            height: 10,
            width: double.infinity,
            color: ThemeConfig.separeColor,
          ),
          Padding(
              padding: EdgeInsets.only(left: 15, top: 10),
              child: Row(
                children: [
                  Text(
                    '充值金额',
                    style: TextThemeConfig.Font15WithColor22,
                  ),
                  Padding(padding: EdgeInsets.only(left: 20)),
                  Expanded(
                    child: TextField(
                      style: TextThemeConfig.Font14WithColor22,
                      controller: state.moneyController,
                      keyboardType: TextInputType.numberWithOptions(decimal: true),
                      decoration: InputDecoration(
                        border: InputBorder.none,
                        hintText: "请输入充值金额",
                        hintStyle: TextThemeConfig.Font14WithColor99,
                        contentPadding: EdgeInsets.only(),
                      ),
                    ),
                  ),
                ],
              )
          ),
          Container(
            margin: EdgeInsets.only(left: 15,right: 15,top: 6),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(4)),
              color: Color(0xffF7F8FA),
            ),
            padding: EdgeInsets.only(left: 15,right: 15),
            width: double.infinity,
            height: 50,
            child: Row(
              children: [
                Padding(padding: EdgeInsets.only(right: 12),child: Image.asset('images/ic_zfb.png'),),
                Text('支付宝支付',style: TextThemeConfig.Font14WithColor22,),
                Expanded(child: Container()),
                Image.asset('images/cricle_select.png'),
              ],
            ),
          ),
          Container(
            height: 50,
            width: double.infinity,
            margin: EdgeInsets.only(left: 15,right: 15,top: 40),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(4)),
              color: ThemeConfig.mainColor,
            ),
            child: MyInkWellWidget(
              child: Center(
                child: Padding(
                  padding: EdgeInsets.only(bottom: 1),
                  child: Text('确认充值',style: TextThemeConfig.Font16WithWhite,),
                ),
              ),
              onTap: ()=> dispatch(GasChargeViewActionCreator.onSubmit()),
            ),
          )
        ],
      ),
      onTap: ()=> CommonUtils.closeKey(viewService.context),
    ),
  );
}
